﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebMMS.Manager
{
    public partial class TaskEdit : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (Session["CurUser"] == null)
                {
                    Response.Redirect("~/Login.aspx");
                    return;
                }
                if (!IsPostBack)
                {
                    string strID = string.Empty;
                    if (Request.QueryString["ID"] != null)
                        strID = Request.QueryString["ID"].ToString();
                    if (string.IsNullOrEmpty(strID))
                    {
                        btnSave.Text = "添 加";
                    }
                    else
                    {
                        lbID.Text = strID;
                        ViewState["ID"] = strID;
                        btnSave.Text = "保 存";
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        //protected void btnSave_Click(object sender, EventArgs e)
        //{
        //    try
        //    {
        //        if (string.IsNullOrEmpty(txtName.Text.Trim()))
        //        {
        //            MM.Common.Common.PageStartAlert(this.Page, "任务名称不能为空！");
        //            return;
        //        }
        //        if (ViewState["ID"] != null && !string.IsNullOrEmpty(ViewState["ID"].ToString()))
        //        {
        //            MM.DBUtility.DbHelperSql.ExecuteSql(string.Format("UPDATE T_Rules SET ChannelNO='{0}',SendCount={1},NextTime='{2}',TimeInterval='{3}',Status='{4}' WHERE ID={5}", ddlChannel.SelectedValue, txtCount.Text.Trim(), inputDate.Value.Trim(), txtTimeInterval.Text.Trim(), ddlStatus.SelectedValue, ViewState["ID"].ToString()));
        //            MM.Common.Common.PageAlertAndRedirect(this.Page, "更新成功！", "MruleManage.aspx");
        //        }
        //        else
        //        {
        //            string strProvinceID = MM.DBUtility.BLSqlData.GetProvinceIDbyQuickName(txtProvince.TextValue);
        //            if (string.IsNullOrEmpty(strProvinceID))
        //            {
        //                MM.Common.Common.PageStartAlert(this.Page, "必须选择省份，或省份选择错误！");
        //                return;
        //            }

        //            if (BLSqlData.ExistRules(strProvinceID, ddlODEP.SelectedValue, ddlCustomer.SelectedValue))
        //            {
        //                MM.Common.Common.PageStartAlert(this.Page, "省份,运营商,客户编号对应的规则已经存在！");
        //                return;
        //            }

        //            MM.DBUtility.DbHelperSql.ExecuteSql(string.Format("insert into T_Rules(ProvinceID,ONO,CNO,ChannelNO,SendCount,NextTime,Status,TimeInterval) values({0},'{1}','{2}','{3}',{4},'{5}','{6}','{7}')", strProvinceID, ddlODEP.SelectedValue, ddlCustomer.SelectedValue, ddlChannel.SelectedValue, txtCount.Text.Trim(), inputDate.Value.Trim(), ddlStatus.SelectedValue, txtTimeInterval.Text.Trim()));
        //            MM.DBUtility.BLSqlData.InsertLogs(userModel.UserID, string.Format("添加了规则信息：ProvinceID={0},ONO={1},CNO={2}。", strProvinceID, ddlODEP.SelectedValue, ddlCustomer.SelectedValue), "规则管理");

        //            MM.Common.Common.PageAlertAndRedirect(this.Page, "添加成功！", "MruleManage.aspx");
        //        }
        //    }
        //    catch (Exception ex)
        //    {

        //        throw ex;
        //    }
        //}
    }
}